import unittest
from api.ihrm_emp_add_delete_update_select import TestIhrmADUS
from common.assert_ulit import assert_ulit
from common.db_util import DButil
from common.get_header import get_header
from common.read_json_util import read_json_data
from config import TEL, BASE_DIR
from parameterized import parameterized


class TestEmpAddParams(unittest.TestCase):
    path_filename = BASE_DIR + "/data/ihrm_json_data.json"

    @classmethod
    def setUpClass(cls) -> None:
        cls.header = get_header()

    def setUp(self) -> None:
        # 删除手机号  (格式化)
        delete_sql = f"delete from bs_user where mobile = '{TEL}'"
        DButil.uid_db(delete_sql)

    def tearDown(self) -> None:
        # 删除手机号  (格式化)
        delete_sql = f"delete from bs_user where mobile = '{TEL}'"
        DButil.uid_db(delete_sql)

    @parameterized.expand(read_json_data(path_filename))
    def test01_add(self, desc, json_data, stauts_code, success, code, message):
        res = TestIhrmADUS.add_tmp(self.header, json_data)
        print(desc, "添加-必选", res.json())
        # 断言
        assert_ulit(self, res, stauts_code, success, code, message)

        # self.assertEqual(200,res.status_code)
        # self.assertEqual(True,res.json().get("success"))
        # self.assertEqual(10000, res.json().get("code"))
        # self.assertIn('操作成功！', res.json().get("message"))

    # # 添加员工
    # def test01_add_emp(self):
    #     # 准备数据
    #     header = {"Content-Type": "application/json", "Authorization": "Bearer 7d135066-b65a-4adb-897c-0017ec0c1f83"}
    #     json_data = {"username": "业务猪018", "mobile": TEL, "workNumber": "9527"}
    #     res = TestIhrmADUS.add_tmp(header, json_data)
    #     print("添加-必选", res.json())
    #     # 断言
    #     assert_ulit(self, res, 200, True, 10000, '操作成功！')
    #
    #     # self.assertEqual(200,res.status_code)
    #     # self.assertEqual(True,res.json().get("success"))
    #     # self.assertEqual(10000, res.json().get("code"))
    #     # self.assertIn('操作成功！', res.json().get("message"))
    #
    # # 组合参数
    # def test02_add_emp(self):
    #     # 准备数据
    #     header = {"Content-Type": "application/json", "Authorization": "Bearer 7d135066-b65a-4adb-897c-0017ec0c1f83"}
    #     json_data = {"username": "业务猪018", "mobile": TEL, "workNumber": "9527", "formfoEMP": "2"}
    #     res = TestIhrmADUS.add_tmp(header, json_data)
    #     print("添加-组合", res.json())
    #     # 断言
    #     assert_ulit(self, res, 200, True, 10000, '操作成功！')
    #
    # # 全部参数
    # def test03_add_emp(self):
    #     # 准备数据
    #     header = {"Content-Type": "application/json", "Authorization": "Bearer 7d135066-b65a-4adb-897c-0017ec0c1f83"}
    #     json_data = {
    #         "username": "大猪乔治",
    #         "mobile": TEL,
    #         "timeOfEntry": "2021-12-01",
    #         "formOfEmployment": 1,
    #         "workNumber": "777888",
    #         "departmentName": "测试",
    #         "departmentId": "1452603344685203456",
    #         "correctionTime": "2021-12-30T16:00:00.000Z"
    #     }
    #     res = TestIhrmADUS.add_tmp(header, json_data)
    #     print("全部参数", res.json())
    #     # 断言
    #     assert_ulit(self, res, 200, True, 10000, '操作成功！')
